import java.util.Arrays;
import java.util.Random;

public class TestSort {


    public static void testInsertSort(int[] array){
        Sort sort = new Sort();
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        sort.insertSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("直接插入排序耗时"+(endTime-startTime));
    }
    public static void testShellSort(int[] array){
        Sort sort = new Sort();
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        sort.shellSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗时"+(endTime-startTime));
    }
    public static void testselectSort(int[] array){
        Sort sort = new Sort();
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        sort.selectSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("选择排序耗时"+(endTime-startTime));
    }
    public static void testHeapSort(int[] array){
        Sort sort = new Sort();
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        sort.heapSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("堆排序耗时"+(endTime-startTime));
    }
    public static void testbubbleSort(int[] array){
        Sort sort = new Sort();
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        sort.bubbleSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("冒泡排序耗时"+(endTime-startTime));
    }
    public static void testHoearquickSort(int[] array){
        Sort sort = new Sort();
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        sort.quickSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("Hoare快速排序耗时"+(endTime-startTime));
    }

    public static void InitNotOrder(int[] array){
        Random random = new Random();
        for(int i = 0;i< array.length;i++){
            array[i] = random.nextInt(10_0000);
        }
    }
    public static void main1(String[] args){
        int[] array = new int[10_0000];
        Sort sort = new Sort();
        InitNotOrder(array);
        testInsertSort(array);
        testShellSort(array);
        testselectSort(array);
        testHeapSort(array);
        testbubbleSort(array);
        testHoearquickSort(array);
    }
    public static void main(String[] args){
        int[] array = {9,1,2,5,7,4,8,6,3,5};
        Sort sort = new Sort();
//      sort.insertSort(array);
//      sort.shellSort(array);
//      sort.heapSort(array);
//      sort.bubbleSort(array);
        sort.quickSort(array);
        System.out.println(Arrays.toString(array));
    }
}
